home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_repeater_m.cog < prev    next >
Text File  |  1998-02-25  |  9KB  |  339 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # WEAP_REPEATER.COG
  4. #
  5. # WEAPON 6 Script - Repeater
  6. # This is the same rifle that was in Dark Forces with the heat sink shield and the
  7. # three barrel design. It is a rapid fire rifle. With the option button you can fire
  8. # all three barrels at once at a slower rate.
  9. #
  10. # - Affected by MagSealed sectors/surfaces.
  11. #
  12. # [YB & CYW]
  13. #
  14. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  15.  
  16.  
  17. symbols
  18.  
  19. model       povModel=rptv.3do                   local
  20. model       povModel_m=rptv_m.3do               local
  21. model       weaponMesh=rptg.3do                 local
  22.  
  23. keyframe    mountAnim=RptVmnt.key               local
  24. keyframe    dismountAnim=RptVdis.key            local
  25. keyframe    povfireAnim=RptVpst1.key            local
  26. keyframe    holsterAnim=kyhlstr.key             local
  27.  
  28. sound       mountSound=df_bry_ready.wav         local
  29. sound       dismountSound=PutWeaponAway01.wav   local
  30. sound       fireSound=rpeatrlp.wav              local
  31. sound       fireSound1=repeat-1.wav             local
  32. sound       outSound=trprout.wav                local
  33. sound            failSound=weapfail.wav                    local
  34.  
  35. vector      fireOffset                          local
  36. vector      adjOffset                           local
  37. vector      shakePos                            local
  38. vector      shakeAngle                          local
  39.  
  40. template    projectile=+repeaterball            local
  41. template    projectileB=+swsparks                 local
  42.  
  43. thing       player                              local
  44.  
  45. flex        fireWait=0.1                        local
  46. flex        powerBoost                          local
  47. flex        lastFireTime=0                      local
  48. flex        curFireTime=0                       local
  49. flex        autoAimFOV=25                       local
  50. flex        autoAimMaxDist=5                    local
  51. flex        numExpectedFires                    local
  52. flex        extraSimTime                        local
  53. flex        holsterWait                         local
  54.  
  55. int         trackID=-1                          local
  56. int         mode                                local
  57. int         fireChannel=-1                      local
  58. int         dummy                               local
  59. int         ammoCost                            local
  60. int         holsterTrack                        local
  61.  
  62. message     startup
  63. message     activated
  64. message     deactivated
  65. message     selected
  66. message     deselected
  67. message     newplayer
  68. message     killed
  69. message     autoselect
  70. message     fire
  71. message     timer
  72.  
  73. end
  74.  
  75. # ========================================================================================
  76.  
  77. code
  78.  
  79. startup:
  80.    player = GetLocalPlayerThing();
  81.    fireOffset = '0.0186 0.0102 0.00';
  82.  
  83.    Return;
  84.  
  85. # ........................................................................................
  86.  
  87. activated:
  88.    mode   = GetSenderRef();
  89.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  90.  
  91.    if(mode > 1) Return;
  92.  
  93.     SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  94.  
  95.     if (GetInv(player, 93) > 0.0)
  96.     {
  97.         mode = 1;
  98.         SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  99.     }
  100.  
  101.    if (mode == 0) ammoCost = 1.0;
  102.    else if (mode == 1) ammoCost = 3.0;
  103.    if(GetInv(player, 12) < ammoCost)
  104.    {
  105.       PlaySoundThing(outSound, player, 1.0, -1, -1, 0x180);
  106.       Return;
  107.    }
  108.  
  109.    if (mode == 0)
  110.    {
  111.       if(fireChannel == -1)
  112.          fireChannel = PlaySoundThing(fireSound, player, 1.0, -1, -1, 0x181);
  113.       fireWait = 0.1;
  114.    }
  115.    else
  116.    if (mode == 1)
  117.    {
  118.       fireWait = 0.3;
  119.    }
  120.  
  121.    powerBoost = GetInv(player, 63);
  122.    ActivateWeapon(player, fireWait/powerBoost, mode);
  123.    jkPlayPOVKey(player, povfireAnim, 1, 0x38);
  124.  
  125.    Return;
  126.  
  127. # ........................................................................................
  128.  
  129. fire:
  130.    mode = GetSenderRef();
  131.  
  132.    // Check that the player is still alive.
  133.    if(GetThingHealth(player) <= 0)
  134.    {
  135.       if(fireChannel != -1)
  136.       {
  137.          StopSound( fireChannel, 0.1 );
  138.          fireChannel = -1;
  139.          dummy = PlaySoundThing(fireSound1, player, 1.0, -1, -1, 0x180);
  140.       }
  141.       Return;
  142.    }
  143.  
  144.    if (mode == 0) ammoCost = 1.0;
  145.    else
  146.    if (mode == 1) ammoCost = 3.0;
  147.  
  148.    if(GetInv(player, 12) < ammoCost)
  149.    {
  150.       if (fireChannel != -1)
  151.       {
  152.          StopSound( fireChannel, 0.1 );
  153.          fireChannel = -1;
  154.          dummy = PlaySoundThing(fireSound1, player, 1.0, -1, -1, 0x180);
  155.       }
  156.  
  157.       if(GetAutoSwitch() & 1)
  158.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  159.  
  160.       Return;
  161.    }
  162.  
  163.    shakePos = VectorScale(RandVec(),.001);
  164.    shakeAngle = VectorScale(RandVec(),1);
  165.    SetPOVShake(shakePos, shakeAngle, .05, 80.0);
  166.  
  167.    if (mode == 0)
  168.    {
  169.         if (GetInv(player, 93) > 0.0)
  170.             dummy = FireProjectile(player, projectileB, -1, 8, fireOffset, '0 0 0', 1.0, 0x30, autoAimFOV, autoAimFOV*2 );
  171.         else
  172.             dummy = FireProjectile(player, projectile, -1, 8, fireOffset, '0 0 0', 1.0, 0x30, autoAimFOV, autoAimFOV*2 );
  173.    }
  174.    else
  175.    if (mode == 1)
  176.    {
  177.         if (GetInv(player, 93) > 0.0)
  178.         {
  179.             dummy = FireProjectile(player, projectileB, failSound, 8, fireOffset, '4.0 0 0', 1.0, 0, autoAimFOV, autoAimMaxDist );
  180.             dummy = FireProjectile(player, projectileB, -1, 8, fireOffset, '-2.5 2.5 0', 1.0, 0, autoAimFOV, autoAimMaxDist );
  181.             dummy = FireProjectile(player, projectileB, -1, 8, fireOffset, '-2.5 -2.5 0', 1.0, 0, autoAimFOV, autoAimMaxDist );
  182.         }
  183.         else
  184.         {
  185.             dummy = FireProjectile(player, projectile, fireSound1, 8, fireOffset, '4.0 0 0', 1.0, 0, autoAimFOV, autoAimMaxDist );
  186.             dummy = FireProjectile(player, projectile, -1, 8, fireOffset, '-2.5 2.5 0', 1.0, 0, autoAimFOV, autoAimMaxDist );
  187.             dummy = FireProjectile(player, projectile, -1, 8, fireOffset, '-2.5 -2.5 0', 1.0, 0, autoAimFOV, autoAimMaxDist );
  188.         }
  189.    }
  190.  
  191.    ChangeInv(player, 12, -ammoCost);
  192.  
  193.    powerBoost = GetInv(player, 63);
  194.    ChangeFireRate(player, fireWait/powerBoost);
  195.  
  196.    if(GetInv(player, 12) == 0)
  197.    {
  198.       if (fireChannel != -1)
  199.       {
  200.          StopSound( fireChannel, 0.1 );
  201.          fireChannel = -1;
  202.          dummy = PlaySoundThing(fireSound1, player, 1.0, -1, -1, 0x180);
  203.       }
  204.  
  205.       if(GetAutoSwitch() & 1)
  206.          SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  207.    }
  208.  
  209.    Return;
  210.  
  211. # ........................................................................................
  212.  
  213. deactivated:
  214.    mode = GetSenderRef();
  215.  
  216.     if (GetInv(player, 93) > 0.0)
  217.     {
  218.         SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  219.         mode = 1;
  220.     }
  221.     
  222.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  223.    if(fireChannel != -1)
  224.    {
  225.       StopSound( fireChannel, 0.1);
  226.       fireChannel = -1;
  227.       PlaySoundThing(fireSound1, player, 1.0, -1, -1, 0x180);
  228.    }
  229.    DeactivateWeapon( player, mode );
  230.  
  231.    Return;
  232.  
  233. # ........................................................................................
  234.  
  235. selected:
  236.    PlayMode(player, 41);
  237.    PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
  238.  
  239.     if (GetInv(player, 67) == 0.0)
  240.         jkSetPOVModel(player, povModel);        // Kyle hand
  241.     else
  242.         jkSetPOVModel(player, povModel_m);    // Mara Hand
  243.    SetArmedMode(player, 1);
  244.    jkSetWeaponMesh(player, weaponMesh);
  245.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  246.  
  247.    trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
  248.    SetMountWait(player, GetKeyLen(mountAnim));
  249.  
  250.    jkClearFlags(player, 0x5);
  251.    SetCurWeapon(player, 6);
  252.  
  253.    Return;
  254.  
  255. # ........................................................................................
  256.  
  257. deselected:
  258.    if(fireChannel != -1)
  259.    {
  260.       StopSound(fireChannel, 0.1);
  261.       fireChannel = -1;
  262.    }
  263.  
  264.    PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
  265.    jkPlayPOVKey(player, dismountAnim, 0, 18);
  266.  
  267.    holsterWait = GetKeyLen(holsterAnim);
  268.    SetMountWait(player, holsterWait);
  269.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  270.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  271.    if (trackID != -1)
  272.    {
  273.       jkStopPOVKey(player, trackID, 0);
  274.       trackID = -1;
  275.    }
  276.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  277.  
  278.    Return;
  279.  
  280. # ........................................................................................
  281.  
  282. newplayer:
  283. //   // Make sure that if the player is respawning, the old mount isn't playing anymore.
  284. //   if(trackID != -1) jkStopPOVKey(player, trackID, 0);
  285.  
  286.    if(fireChannel != -1)
  287.    {
  288.       StopSound(fireChannel, 0.1);
  289.       fireChannel = -1;
  290.    }
  291.  
  292.    Return;
  293.  
  294. # ........................................................................................
  295.  
  296. killed:
  297.    if (player == GetSenderRef())
  298.    {
  299.       if(fireChannel != -1)
  300.       {
  301.          StopSound(fireChannel, 0.1);
  302.          fireChannel = -1;
  303.       }
  304.    }
  305.    Return;
  306.  
  307. # ........................................................................................
  308.  
  309. autoselect:
  310.    // If the player has the weapon
  311.    if(GetInv(player, GetWeaponBin(6)) != 0.0)
  312.    {
  313.       // If the player has ammo
  314.       if(GetInv(player, 12) != 0.0)
  315.       {
  316.          ReturnEx(800.0);
  317.       }
  318.       else
  319.       {
  320.          ReturnEx(-1.0);
  321.       }
  322.    }
  323.    else
  324.    {
  325.       ReturnEx(-1.0);
  326.    }
  327.  
  328.    Return;
  329.  
  330. # ........................................................................................
  331.  
  332. timer:
  333.    StopKey(player, holsterTrack, 0.0);
  334.    Return;
  335.  
  336. end
  337.  
  338.  
  339.